#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <string.h>
#include <fstream>
#include "client.h"

using namespace std;

int main(int argc, char * argv[])
{
        std::string IP = "127.0.0.1";
        int Port = 9000;
        std::string username = "root";
        std::string password = "123456";
	std::string db_name = string(argv[1]);
	std::string query = string(argv[2]);
	char buf[10000];
	ifstream fin(query.c_str());
    	memset(buf, 0, sizeof(buf));
    	stringstream _ss;
    	while(!fin.eof())
    	{
        	fin.getline(buf, 9999);
        	_ss << buf << "\n";
    	}
   	fin.close();
	std::string sparql = _ss.str();

	GstoreConnector gc(IP, Port, username, password);
	std::string res = gc.query(db_name, "json", sparql);
	cout << res <<endl;
	return 0;
}
